#!/bin/python3
# -*- coding:utf-8 -*-
"""
    发送消息
    By :陈狍子 e4ting@qq.com 2024-12-14 17:50:23
"""
import sys,os
from pdb import set_trace as strace
from traceback  import format_exc as dumpstack
# from e4ting import util,log

from .wamp import WAMP

class Notify(object):
    """ 消息推送 """
    def __init__(self, uid):
        self.uid = uid
        self.rpc = WAMP(self.uid)

    def brodcast(self, topic="", msg=""):
        # 广播
        uri = "e4ting.{topic}".format(topic=topic)
        self.rpc.pushlish(uri, {'acknowledge':False}, args=[msg])
        return True

    def notify(self, msg=""):
        # 定向推送
        uri = "e4ting.{self.uid}.notify".format(self=self)
        self.rpc.publish(uri, {'acknowledge':False}, args=[msg])
        return True

    def commons(self, msg=""):
        # 定向推送
        uri = "e4ting.{self.uid}.commons".format(self=self)
        self.rpc.publish(uri, {'acknowledge':False}, args=[msg])
        return True

    def all_hands(self, msg=""):
        # 定向推送
        uri = "e4ting.{self.uid}.all_hands".format(self=self)
        self.rpc.publish(uri, {'acknowledge':False}, args=[msg])
        return True

    def all_rates(self, msg=""):
        # 推送得分
        uri = "e4ting.{self.uid}.all_rates".format(self=self)
        self.rpc.publish(uri, {'acknowledge':False}, args=[msg])
        return True

    def progress(self, uid=0, progress=100):
        uri = "e4ting.{self.uid}.progress".format(self=self)
        self.rpc.publish(uri, {'acknowledge':False}, args=[uid, progress])
        return True

    def record(self):
        # 行为记录
        return True
